package com.zhxi.gulimall.search.controller;

import com.zhxi.common.to.es.SkuEsModel;
import com.zhxi.common.utils.R;
import com.zhxi.gulimall.search.service.ProductSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description:
 * @author: zx
 * @date: 2024-10-16 10:07
 * @version: V1.0
 */
@RequestMapping("/search/save")
@RestController
public class ElasticSaveController {
    @Autowired
    ProductSaveService productSaveService;

    /**
     * @param skuEsModels
     * @return {@link R }
     * @description: 上架商品
     * @author: zx
     * @date: 2024-10-16 10:08
     */
    @PostMapping("/product")
    public R productStartUp(@RequestBody List<SkuEsModel> skuEsModels) {
        boolean b;
        try {
            b = productSaveService.productStartUp(skuEsModels);
        } catch (Exception e) {
            return R.error("上架异常");
        }
        return b ? R.ok() : R.error();
    }
}
